package org.zn.plus.mybatis.sql.builder.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.zn.plus.mybatis.sql.builder.constant.Join;

public class JoinTable  extends QueryTable{
	
	private QueryTable linkTable;
	private String joinType=Join.JOIN;
	private List<OnColumn>  OnColumns;
	
	public JoinTable() {};
	
	public JoinTable(QueryTable table) {
		super();
		
		super.setAlias(table.getAlias());
		super.setGroupBys(table.getGroupBys());
		super.setJoinTables(table.getJoinTables());
		super.setOrders(table.getOrders());
		super.setSelectColumns(table.getSelectColumns());
		super.setTableName(table.getTableName());
		super.setWhereColumns(table.getWhereColumns());
		
		OnColumns=Collections.EMPTY_LIST;
		
	};
	
	public String getJoinType() {
		return joinType;
	}
	public void setJoinType(String joinType) {
		this.joinType = joinType;
	}
	public List<OnColumn> getOnList() {
		return OnColumns;
	}
	public void setOnList(List<OnColumn> onList) {
		this.OnColumns = onList;
	}
	
	public void addOnColumns(OnColumn OnColumn) {

		if(OnColumns==null||OnColumns==Collections.EMPTY_LIST) OnColumns=new ArrayList<>();
		OnColumns.add(OnColumn);
		
	}
	
	public QueryTable getLinkTable() {
		return linkTable;
	}
	public void setLinkTable(QueryTable linkTable) {
		this.linkTable = linkTable;
	}

	@Override
	public String fragmentName() {
		return clazz;
	}
	
}
